package com.yanqu.road.server.manager.user;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.IUserBaseInfoSyncListener;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：zfr
 * @date ：2021/8/18 9:55
 */
public class CrossUserNotifyMgr extends TempMgr {
    private static List<IUserBaseInfoSyncListener> listeners = new ArrayList<>();
    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static void addSyncListener(IUserBaseInfoSyncListener syncListener){
        listeners.add(syncListener);
    }

    public static void notifyReload(UserBaseInfo userBaseInfo, long userId){
        for (IUserBaseInfoSyncListener listener : listeners) {
            listener.notifySync(userBaseInfo, userId);
        }
    }
}
